/* Copyright 2011 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.lesscss4j;

import java.util.List;

/**
 * An exception that provides information on a LESS compilation error.
 * 
 * @author Marcel Overdijk
 */
@SuppressWarnings("serial")
public class LessException extends Exception {

    private String name;
    private String type;
    private Integer index;
    private Integer line;
    private Integer column;
    private List<String> extract;
    private Integer callLine;
    private List<String> callExtract;
    
    /**
     * Constructs a new <code>LessException</code>.
     * 
     * @param cause The cause.
     */
    public LessException(Throwable cause) {
        super(cause);
//        if (cause instanceof JavaScriptException) {
//            Scriptable value = (Scriptable)((JavaScriptException)cause).getValue();
//            
//            // TODO remove
//            for (Object id : value.getIds()) {
//                Object val = ScriptableObject.getProperty(value, id.toString());
//                System.out.println("id = " + id + ", val = " + val);
//            }
//            
//            boolean hasName = ScriptableObject.hasProperty(value, "name");
//            boolean hasType = ScriptableObject.hasProperty(value, "type");
//            
//            if (hasName || hasType) {
//                
//                if (hasName) {
//                    name = ScriptableObject.getProperty(value, "name").toString();
//                }
//                
//                if (hasType) {
//                    type = ScriptableObject.getProperty(value, "type").toString();
//                }
//                
//                if (ScriptableObject.hasProperty(value, "index")) {
//                    index = ((Double)ScriptableObject.getProperty(value, "index")).intValue(); 
//                }
//                
//                if (ScriptableObject.hasProperty(value, "line")) {
//                    line = ((Double)ScriptableObject.getProperty(value, "line")).intValue(); 
//                }
//                
//                if (ScriptableObject.hasProperty(value, "column")) {
//                    column = ((Double)ScriptableObject.getProperty(value, "column")).intValue(); 
//                }
//                
//                if (ScriptableObject.hasProperty(value, "extract")) {
//                    extract = new ArrayList<String>();
//                    NativeArray array = (NativeArray)ScriptableObject.getProperty(value, "extract");
//                    for (int i = 0; i < array.getLength(); i++) {
//                        if (array.get(i, array) instanceof String) {
//                            extract.add(((String) array.get(i, array)).replace("\t", " "));
//                        }
//                    }
//                }
//                
//                if (ScriptableObject.hasProperty(value, "callLine")) {
//                    callLine = ((Double)ScriptableObject.getProperty(value, "callLine")).intValue(); 
//                }
//                
//                if (ScriptableObject.hasProperty(value, "callExtract")) {
//                    callExtract = new ArrayList<String>();
//                    NativeArray array = (NativeArray)ScriptableObject.getProperty(value, "callExtract");
//                    for (int i = 0; i < array.getLength(); i++) {
//                        if (array.get(i, array) instanceof String) {
//                            callExtract.add(((String) array.get(i, array)).replace("\t", " "));
//                        }
//                    }
//                }
//            }
//        }
    }
    
//    public String getName() {
//        return name;
//    }
//    
//    public String getType() {
//        return type;
//    }
//    
//    // TODO @Override message
//    
//    public Integer getIndex() {
//        return index;
//    }
//    
//    public int getLine() {
//        return line;
//    }
//    
//    public int getColumn() {
//        return column;
//    }
//    
//    public List<String> getExtract() {
//        return extract;
//    }
//    
//    public int getCallLine() {
//        return callLine;
//    }
//    
//    public List<String> getCallExtract() {
//        return callExtract;
//    }
}
